<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:ic="http://ivyteam.ch/jsf/component"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:pm="http://primefaces.org/mobile">

<cc:interface componentType="IvyComponent">
	<cc:attribute name="task" />
</cc:interface>

<cc:implementation>
	<script>
		$(document).ready(function (){
			$( "." + #{cc.attrs.task.id} ).dblclick(function() {
				loadData(#{cc.attrs.task.id});
			});
		});
	</script>
	<style>
		.noBorders tr, .noBorders td {
		    background: none !important;
		    border: none !important;
		}
		.title{
		 	font-weight:bold;
		 	font-family:  'Times New Roman';
		 	font-size: 16px;"
		}
		.description{
			display:block;
			margin-top:25px !important;
		 	font-style:italic !important;
		 	font-family: verdana, helvetica, arial, sans-serif !important;
		 	font-size: 14px !important;
		 	white-space: normal;
		}
		.assigned{
			margin: 8px 0px 0px -10px !important;
			display:block;
			font-weight:bold;
		 	font-family:  'Times New Roman'; !important;
		 	font-size: 14px !important;
		}
		.textWhite{
			color: white;
		}
	</style>
	<script>
		function reloadWithCheckGrow(){
			if (! $(".ui-growl-item-container").length > 0){
				reloadData();
			};
		}
	</script>
	<h:form styleClass="#{cc.attrs.task.id}">
		<p:growl id="growl" showDetail="true" sticky="true" /> 
		<p:panel style="background: #444444 !important;">
			<f:facet name="header">
                <h:outputLabel value="##{cc.attrs.task.id}" style=" font-family: 'Times New Roman'; font-size:18;"/>
            </f:facet>
			<h:panelGroup id="title" layout="block">
				<h:outputLabel value="#{cc.attrs.task.title}" styleClass="title textWhite"/>
			</h:panelGroup>
			<h:panelGroup id="description" layout="block">
				<h:outputText value="#{cc.attrs.task.description}" styleClass="description textWhite"/>
			</h:panelGroup>
			<h:panelGrid  width="100%" styleClass="noBorders" columns="2">
				<h:outputLabel value="#{cc.attrs.task.assigned}" styleClass="assigned textWhite" rendered="#{cc.attrs.task.status ne 'ready'}"/>
				<h:outputLabel value="" styleClass="assigned" rendered="#{cc.attrs.task.status eq 'ready'}"/>
				<h:panelGroup style="float:right" id="button" layout="block">
					<p:commandButton value="Take" name="btnTake"
						id="btnTake" rendered="#{cc.attrs.task.status eq 'ready'}" styleClass="public-button" actionListener="#{logic.moveTaskToWork(cc.attrs.task.id)}" oncomplete="reloadWithCheckGrow()" update="growl"/>
					<p:commandButton value="Log Work" name="btnLogWork"
						id="btnLogWork" onclick="dlg4.show()"
						rendered="#{cc.attrs.task.status eq 'work' and cc.attrs.task.assigned eq ivy.session.sessionUser.name}" styleClass="public-button"/>
					<p:commandButton value="Resolve" name="btnResolve"
						id="btnResolve"
						rendered="#{cc.attrs.task.status eq 'work'}" styleClass="public-button"/>
					<p:commandButton value="Reject" name="btnReject"
						id="btnReject"
						rendered="#{cc.attrs.task.status eq 'review'}" styleClass="public-button"/>
					<p:commandButton value="Accept" name="btnAccept"
						id="btnAccept"
						rendered="#{cc.attrs.task.status eq 'review'}" styleClass="public-button"/>
					<p:commandButton value="Archive" name="btnArchive"
						id="btnArchive"
						rendered="#{cc.attrs.task.status eq 'done'}" styleClass="public-button"/>
				</h:panelGroup>
			</h:panelGrid>
		</p:panel>
	</h:form>
</cc:implementation>

</html>
